package game.view.mainUI
{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	
	import game.UIComponent.Button;
	import game.UIComponent.Panel;
	import game.UIComponent.TabButton;
	import game.common.CustomBitmap;
	import game.common.Reflection;
	import game.managers.LanguageManager;
	import game.utils.Utils;
	
	
	public class InformationView extends Panel
	{
		private var _bar:CustomBitmap;
		private var _information:CustomBitmap;
		private var _head:CustomBitmap;
		private var _bg:CustomBitmap;
		private var _decide:Button;
		private var _close:Button;
		private var _liuyan:TabButton;
		private var _system:TabButton;
		private var _news:TabButton;
		private var _expend:TabButton;
		private var _name:TextField;
		private var _rank:TextField;
		private var _ranktxt:TextField;
		private var _money:TextField;
		private var _moneytxt:TextField;
		private var _experience:TextField;
		private var _experiencetxt:TextField;
		
		
		private var _first:LiuyanType;
		private var _second:SystemType;
		private var _third:NewsType;
		private var _fourth:ExpendType;
		 
		public function InformationView()
		{
			init();
		}
		
		override protected function init():void
		{
			super.init();
			setBgImage("bg",500,400);
			setCenter();

			_bar=new CustomBitmap();
			_bar.source="bar";
			_bar.x=120;	
			_bar.y=-40;
			addChild(_bar);
			
			setImageTitle("personalText");
			
			_head=new CustomBitmap();
			_head.source="headBg";
			_head.x=50;	
			_head.y=50;
			addChild(_head);
			
			_name=Utils.getCommonTextField(LanguageManager.getWord("message.name"),18,_head.x+_head.width+20,_head.y);
			addChild(_name);
			
			_money=Utils.getCommonTextField(LanguageManager.getWord("message.money"),16,_name.x,_name.y+35);
			addChild(_money);
			_moneytxt=Utils.getTextField(LanguageManager.getWord("message.moneytxt"), 18);
			_moneytxt.x=_money.x+_money.width;
			_moneytxt.y=_money.y;
			addChild(_moneytxt);	
			
			_experience=Utils.getCommonTextField(LanguageManager.getWord("message.experience"),16,_money.x,_money.y+20);
			addChild(_experience);
			_experiencetxt=Utils.getTextField(LanguageManager.getWord("message.experiencetxt"), 18);
			_experiencetxt.x=_experience.x+_experience.width;
			_experiencetxt.y=_experience.y;
			addChild(_experiencetxt);
			
			_rank=Utils.getCommonTextField(LanguageManager.getWord("message.level"),16,_experience.x,_experience.y+20);
			addChild(_rank);
			_ranktxt=Utils.getTextField(LanguageManager.getWord("message.leveltxt"), 18);
			_ranktxt.x=_rank.x+_rank.width;
			_ranktxt.y=_rank.y;
			addChild(_ranktxt);
			
		 
			_liuyan=new TabButton(LanguageManager.getWord("message"),liuyanclickHandler);
			_liuyan.x=_head.x+10;
			_liuyan.y=_head.y+_head.height+10;	
			_now=_liuyan;
			_liuyan.scaleX=0.6;
			_liuyan.choose=true;
		    addChild(_liuyan);
	
			
			
			_system=new TabButton(LanguageManager.getWord("system"),liuyanclickHandler);
			_system.x=_liuyan.x+50;
			_system.y=_liuyan.y;
			_system.scaleX=0.6;
			addChild(_system);
			
			_news=new TabButton(LanguageManager.getWord("news"),liuyanclickHandler);
			_news.x=_system.x+50;
			_news.y=_system.y;
			_news.scaleX=0.6;
			addChild(_news);

			
			_expend=new TabButton(LanguageManager.getWord("expend"),liuyanclickHandler);
			_expend.x=_news.x+50;
			_expend.y=_news.y;	
			_expend.scaleX=0.6;
			addChild(_expend);

			
			_bg=new CustomBitmap();
			_bg.source="liuyanbg";
			_bg.x=_head.x;	
			_bg.y=_liuyan.y+35;
			addChild(_bg);
			
			_first=new LiuyanType();
			_first.x=_head.x;
			_first.y=_liuyan.y+35 ;
			_liuyan.binding=_first;
			addChild(_first);
			
			_second=new SystemType();
			_second.x=_first.x;
			_second.y=_first.y ;
			_second.visible=false;
			_system.binding=_second;
			addChild(_second);
		 
			_third=new NewsType();
			_third.x=_second.x;
			_third.y=_second.y ;
			_third.visible=false;
			_news.binding=_third;
			addChild(_third);
			
			_fourth=new ExpendType();
			_fourth.x=_third.x;
			_fourth.y=_third.y ;
			_fourth.visible=false;
			_expend.binding=_fourth;
			addChild(_fourth);
			
			_decide=new Button("","confirm1");
			_decide.name="confirm1";
			_decide.x=215;
			_decide.y=345;	
			_decide.addEventListener(MouseEvent.CLICK,clickHandler);
			addChild(_decide);
			
			_close=new Button("","close1");
			_close.name="close1";
			_close.x=_bar.x+_bar.width+50;
			_close.y=_bar.y+10;
			_close.addEventListener(MouseEvent.CLICK,clickHandler);
			addChild(_close);
			

			
		}
		
		private function clickHandler(e:MouseEvent):void
		{
			this.isPop=false;
			
		}

		
		private var _now:TabButton;
		
		private function liuyanclickHandler(e:MouseEvent):void
		{
			var btn:TabButton = e.target as TabButton;
			if(btn == _now) return;
			if(_now)_now.choose = false;
			btn.choose = true;
			_now = btn;
			
			switch(btn){
				case _liuyan:
					break;
				case _system:
					break;
				case _news:
					break;
				case _expend:
					break;
			}
		}
		
		
		
	}
}